using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XLua;

//在Unity中执行lua脚本
//调用Lua中声明的变量
public class Lesson4_CallVariable : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        LuaMgr.GetInstance().Init();

        LuaMgr.GetInstance().DoFile("Main");

        //使用Lua解析器luaenv中的Global属性
        int i = LuaMgr.GetInstance().Global.Get<int>("testNumber");
        LuaMgr.GetInstance().Global.Set("testNumber", 111);
        int i2 = LuaMgr.GetInstance().Global.Get<int>("testNumber");
        Debug.Log("i = " + i);
        Debug.Log("i2 = " + i2);

        int local = LuaMgr.GetInstance().Global.Get<int>("testLocal");
        Debug.Log("local = " + local);
        
        
        bool b = LuaMgr.GetInstance().Global.Get<bool>("testBool");
        float f = LuaMgr.GetInstance().Global.Get<float>("testFloat");
        string s = LuaMgr.GetInstance().Global.Get<string>("testString");

        Debug.Log("testBool = " + b);
        Debug.Log("testFloat = " + f);
        Debug.Log("testString = " + s);
    }


    void Update()
    {

    }
}
